package hotciv.view.tool;

import hotciv.framework.City;
import hotciv.framework.Game;
import hotciv.framework.Position;
import hotciv.framework.Unit;
import hotciv.view.GfxConstants;

import java.awt.event.MouseEvent;

import minidraw.framework.Drawing;
import minidraw.framework.DrawingEditor;
import minidraw.framework.Figure;
import minidraw.standard.NullTool;

public class NextTurnTool extends NullTool 
{
	private Game game;
	private DrawingEditor editor;
	private int width, height = 0;

	public NextTurnTool(DrawingEditor editor, Game game) 
	{
		this.editor = editor;
		this.game = game;
		Drawing d = this.editor.drawing();
		Figure shield = d.findFigure(GfxConstants.TURN_SHIELD_X, GfxConstants.TURN_SHIELD_Y);
		if (d!=null) {
			width = shield.displayBox().width;
			height = shield.displayBox().height;
		}
	}

	public void mouseUp(MouseEvent e, int x, int y) 
	{
		 if (x>=GfxConstants.TURN_SHIELD_X && x <= GfxConstants.TURN_SHIELD_X+width && y >= GfxConstants.TURN_SHIELD_Y && y <= GfxConstants.TURN_SHIELD_Y + height) {
			 game.endOfTurn();
		 }
	}
}
